package com.jianbing.shasha.controller;

import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.page.TableDataInfo;
import com.jianbing.shasha.domain.*;
import com.jianbing.shasha.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.jianbing.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/shasha/data/list")
public class ShashaDataController extends BaseController{

    @Autowired
    private IShashaUserRecordService shashaUserRecordService;
    @Autowired
    private IShashaUserInfoService shashaUserInfoService;
    @Autowired
    private IShashaUserAccuracyService shashaUserAccuracyService;
    @Autowired
    private IShashaUserAchieveService shashaUserAchieveService;
    @Autowired
    private IShashaStudyService shashaStudyService;

//    @GetMapping("/accuracy")
//    public TableDataInfo getAccuracy(ShashaAccuracyVo shashaAccuracyVo){
//        startPage();
//        List<ShashaAccuracyVo> list = shashaUserRecordService.getAccuracy(shashaAccuracyVo);
//        return getDataTable(list);
//    }

    @GetMapping("/accuracy")
    public TableDataInfo listAccuracy(ShashaUserAccuracy shashaUserAccuracy)
    {
        startPage();
        List<ShashaUserAccuracy> list = shashaUserAccuracyService.selectShashaUserAccuracyList(shashaUserAccuracy);
        return getDataTable(list);
    }

    @GetMapping("/user-info")
    public TableDataInfo getUserInfo(ShashaUserInfo shashaUserInfo){
        startPage();
        List<ShashaUserInfo> list = shashaUserInfoService.selectShashaUserInfoList(shashaUserInfo);
        return getDataTable(list);
    }

    @PostMapping("/record")
    public TableDataInfo getRecord(ShashaRecordVO recordVO){
        startPage();
        List<ShashaRecordVO> list = shashaUserRecordService.selectShashaStudyRecord(recordVO);
        return getDataTable(list);
    }

    @GetMapping("/achieve")
    public TableDataInfo list(ShashaUserAchieve shashaUserAchieve)
    {
        startPage();
        List<ShashaUserAchieve> list = shashaUserAchieveService.selectShashaUserAchieveList(shashaUserAchieve);
        return getDataTable(list);
    }

//    private String emotion2Answer(String emotion){
//        if(emotion.equals("happy")){
//            return "kai"
//        }
//    }

    private Map<Long,Long> getStudyId(Long level){
        Map<Long,Long> map = new HashMap<>();
        ShashaStudy shashaStudy = new ShashaStudy();
        shashaStudy.setLevelId(level);
        List<ShashaStudy> list = shashaStudyService.selectShashaStudyList(shashaStudy);
        for(ShashaStudy tmp:list){
            map.put(tmp.getId(),tmp.getStudyId());
        }
        return map;
    }
}
